# Duplex Index Data File
#
# Building by using BMake
#
# $ DIDF: Makefile    Rev. 0.1.0    2014-04-16T23:25+08:00 $

.include <../../Makefile.mk>

CFLAGS= -O2 -Wall

STATIC_OBJS= libdid.a
SHARED_OBJS= libdid.so

BUILD_OBJS= ${STATIC_OBJS}

.ifndef WITHOUT_SHARED
BUILD_OBJS+= ${SHARED_OBJS}
.endif


EXEC_OBJS= txtf2did didview diddraw

BUILD_OBJS+= ${EXEC_OBJS}


build: ${BUILD_OBJS}

# Library Archive
libdid.a: did.o
	${AR} libdid.a did.o

libdid.so: did.o
	${LD} -shared -soname libdid.so -o libdid.so.0 did.o
	${LN} ./libdid.so.0 ./libdid.so

did.o: did.c
	${STDCC} -fpic -c did.c ${CFLAGS} -I./


# Text Format File To DID File
txtf2did: cvtflt.o libdid.a
	${STDCC} -o txtf2did cvtflt.o libdid.a

cvtflt.o: cvtflt.c
	${STDCC} -c cvtflt.c ${CFLAGS} -I./


# Text Viewer For DID File
didview: didview.o libdid.a
	${STDCC} -o didview didview.o libdid.a -lm

didview.o: didview.c
	${STDCC} -c didview.c ${CFLAGS} -I./


# Draw 2D Image File For Sparsity
diddraw: diddraw.o libdid.a
	${STDCC} -o diddraw diddraw.o libdid.a -L${PNG_LIB} -lpng

diddraw.o: diddraw.c
	${STDCC} -c diddraw.c ${CFLAGS} -I./ -I${PNG_INC}


# Clean All Build or Core Dump
clean:
	${RM} *.o
	${RM} *.a
	${RM} *.so
	${RM} *.so.0
	${RM} ${BUILD_OBJS}
	${RM} *.core
